import Vue from 'vue'
import Vuex from 'vuex'
import name from 'vuex-persist'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    bg:'#F39894',
    show:false,
    affair:[]
  },
  mutations: {
    show(state){
      state.show = !state.show;
    },
    qbg(state,color){
      state.bg = color
    },
    add(state,value){
      state.affair.push({
        name:value,
        code:0,
        cTime:new Date().toLocaleString()
      })
    },
    change(state,index){
      state.affair[index].code = 1;
      state.affair[index].cTime = new Date().toLocaleString();

    
    },
    out(state,index){
      state.affair[index].code =2;
      state.affair[index].cTime = new Date().toLocaleString();
    },
    recovery(state,index){
      state.affair[index].code = 0;
    }
  },
  actions: {},
  modules: {},
  plugins: [
    new name({
      storage: window.localStorage,
    }).plugin,
  ],
})